package com.livesource.client;

import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.livesource.client.model.entry.ProjectClass;

public class GetProjectFeatures {

	public static JSONArray get() {

		JSONArray jsonTasks = new JSONArray();

		if (LiveSourceGlobalVariables.projectEntries != null) {

			int i = 0;

			for (ProjectClass entry : LiveSourceGlobalVariables.projectEntries
					.values()) {

				JSONObject task = new JSONObject();

				if (entry.getStatus() != null) {

					task.put("status", new JSONString(entry.getStatus()));
				}

				if (entry.getFeatureType() != null) {

					task.put("type", new JSONString(entry.getFeatureType()));
				}

				if (entry.getFeatureName() != null) {

					task.put("name", new JSONString(entry.getFeatureName()));
				}

				if (entry.getFeatureDescription() != null) {

					task.put("description",
							new JSONString(entry.getFeatureDescription()));
				}

				jsonTasks.set(i, task);

				i++;
			}
		}

		return jsonTasks;
	}
}
